function [steps rew] = correrMCar(mdp,tiles,w)

s = [0 0];% mdp.getRandomState(mdp);
steps=1;
max_steps=1000;
rew=zeros(1,max_steps);
eoe=false;
while(~eoe && steps<max_steps)
    t = getFactors(tiles, s);
    for i=1:length(mdp.actions)
        Q(i) = w(i,:)*t';
    end
    [~,a]=max(Q);
    [s_next,r,eoe]= mdp.simularAmbiente(mdp, s,mdp.actions(a));
    
    MountainCarPlot(s,a,steps);
    pause(0.01);
    rew(steps)=r;
    steps=steps+1;
    s=s_next;
end
steps=steps-1;
end